{% extends "base.html" %}
{% block base %}

<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
                    aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">陈勇志的接口测试平台</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-right">
                <li><a href="#">设置</a></li>
                <li><a href="/logout/">退出</a></li>
            </ul>
            <form class="navbar-form navbar-right">
                <input type="text" class="form-control" placeholder="搜索...">
            </form>
        </div>
    </div>
</nav>

<div class="container-fluid">
    <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
            <ul class="nav nav-sidebar">
                <li><a href="/project/"><i class="glyphicon glyphicon-th-large">&nbsp;</i>项目管理 <span class="sr-only">(current)</span></a>
                </li>
                <li><a href="/module/"><i class="glyphicon glyphicon-th">&nbsp;</i>模块管理</a></li>
            </ul>
            <ul class="nav nav-sidebar">
                <li class="active"><a href="/case_manage/">用例管理</a></li>
                <li><a href="/task_manage/">任务管理</a></li>
            </ul>
            <ul class="nav nav-sidebar">
                <li><a href="">mock server</a></li>
                <li><a href="">测试工具</a></li>
                <li><a href="">更多工具</a></li>
            </ul>
        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <!--用例列表-->
            <h4 class="sub-header">用例列表
                <button type="button" onclick="location.href='/case_manage/case_create/'" class="btn btn-sm btn-primary"
                        style="float:right">新建
                </button>
            </h4>
            <div class="table-responsive">
                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th>id</th>
                        <th>用例名称</th>
                        <th>URL</th>
                        <th>是否执行</th>
                        <th>所属模块</th>
                        <th>创建日期</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for each_case in test_cases %}
                    <tr>
                        <td>{{ each_case.id }}</td>
                        <td>{{ each_case.name }}</td>
                        <td>{{ each_case.url }}</td>
                        <td>{{ each_case.is_run }}</td>
                        <td>{{ each_case.module_id }}</td>
                        <td>{{ each_case.create_time | date:"Y-m-d H:i:s" }}</td>
                        <td>
                            <!--编辑按钮-->
                            <a href="/case_manage/case_edit/{{ each_case.id }}/">
                                <i class="glyphicon glyphicon-pencil"></i>
                            </a>
                            <!--删除按钮-->
                            <a href="/case_manage/case_del/{{ each_case.id }}/">
                                <i style="padding-left:5px;" class="glyphicon glyphicon-trash"></i>
                            </a>
                        </td>
                    </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
            <div>
                <!--        分页-->
                <nav aria-label="Page navigation" style="margin-left:700px">
                    <ul class="pagination">
                        <li>
                            {% if test_cases.has_previous %}
                            <a href="?page={{ test_cases.previous_page_number }}" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                            {% endif %}
                        </li>
                        {% for pg in test_cases.paginator.page_range %}
                        {% if test_cases.number == pg %}
                        <li class="active"><a href="?page={{ pg }}">{{pg}}</a></li>
                        {% else %}
                        <li><a href="?page={{ pg }}">{{pg}}</a></li>
                        {% endif %}
                        {% endfor %}
                        <li>
                            {% if test_cases.has_next %}
                            <a href="?page={{ test_cases.next_page_number}}" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                            {% endif %}
                        </li>
                    </ul>
                </nav>
            </div>
        </div>
    </div>

</div>

{% endblock %}
